<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<script type="text/javascript">
  Date.prototype.Format = function (fmt) { //author: meizz
    var o = {
      "M+": this.getMonth() + 1, //月份
      "d+": this.getDate(), //日
      "h+": this.getHours(), //小时
      "m+": this.getMinutes(), //分
      "s+": this.getSeconds(), //秒
      "q+": Math.floor((this.getMonth() + 3) / 3), //季度
      "S": this.getMilliseconds() //毫秒
    };
    if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
    for (var k in o)
      if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
    return fmt;
  }
  function setIdNo(){
    getBaseinfo('idNo','age');
    getBirthday('idNo','birthdayDate')
  }
  function showTuanJian(){
    var type=$("#type").val();
    if(type=="0"){
      $("#tuanJian").hide();
      $("#teamGroup").val("");
      $("#teamSelect").val("");
      $("select[name='tInformation.payType']").val("");
      $("#unifiedPrice").val("");
    }else{
      $("#tuanJian").show();
    }
  }
  showTuanJian();
  function tuanJian(){
    $("#type").val($("#tjType").val());
    showTuanJian();
  }
 function clickIn(){
   var id=$("#teamSelect").val();
   $("#tUnitFzDiv").html("");
   loadDiv("tUnitFzDiv","${ctx}/sys/baseUnit/findGroupByUnitId?unitId="+id);
  }
  function print(patientId,clinicId){
      printPdf('${ctx}/tinformation/t_information/tInformation/print','patientId='+patientId+'&clinicId='+clinicId);
  }
  //加载照相
  function upLoadHeadPortrait() {
    loadDiv("photoWindow","${ctx}/physical/image");
  }
  //关闭照相
  function closePhotoWindow(){
    $("#photoWindow").text("");
  }
  //确定照相
  function yesPhotoWindow(){
    //获取照片预览数据（base64格式）
    var c=document.getElementById("canvas");
    var data=c.toDataURL();
    //判断是否拍照过，Is拍过，No没有
    var imageIsNo=$("#imageIsNo").val();
    $("#imageIsNo").val("No");
    //如果拍过照，则将照片预览的数据获取，并赋值给头像
    if(imageIsNo == "Is"){
      //用于存入数据库
      $("#headPortrait").val(data);
      //用于在页面显示
      $("#headImage").attr("src",data);
    }
    closePhotoWindow();
  }
</script>
<div class="panel-body">
  <div id="photoWindow">
  </div>
  <div class="table-responsive no-border">
    <form id="inputPatForm"   method="post" class="form-horizontal" onsubmit="return formSaveLoad('rigthDoctorCenterDiv','inputPatForm','${ctx}/physical/saveUserBasicInfo','${ctx}/physical/userBasicInfo?patientId=${patientId}&clinicId=${clinicId}');">
      <input type="hidden" name="id" value="${basicInfo.id}" >
      <input type="hidden" name="tInformation.id" value="${tInformation.id}" >
      <input type="hidden" name="clinicId" value="${clinicId}" >
      <div class="col-lg-11">
        <div class="opertion_items">
          <div>基本信息</div>
        </div>
        <fieldset>
          <div class="col-lg-4">
            <div class="form-group">
              <label class="col-sm-5 control-label">姓名：</label>
              <div class="col-sm-7">
                <input type="hidden" name="name" value="${basicInfo.name}" >
                <label class="usual_label">${basicInfo.name}</label>

              </div>
            </div>
            <div class="form-group">
              <label class="col-sm-5 control-label">年龄(岁)：</label>
              <div class="col-sm-7">
                <input type="text" name="age" id="age" value="${basicInfo.age}" class="form-control">
              </div>
            </div>
            <div class="form-group">
              <label class="col-sm-5 control-label">身份证号：</label>
              <div class="col-sm-7">
                <input type="text" data-parsley-checkidcard="3"  id="idNo"
                       maxlength="100" name="idNo" onchange="setIdNo()"
                       value="${basicInfo.idNo}" class="form-control">
              </div>
            </div>
            <div class="form-group">
              <label class="col-sm-5 control-label">民族：</label>
              <div class="col-sm-7">
                <sys:select checkValue="${basicInfo.nation}" lists="${fns:getDictList('NATION_DICT')}" className="form-control" name="nation"></sys:select>
              </div>
            </div>
            <div class="form-group">
              <label class="col-sm-5 control-label">出生地：</label>
              <div class="col-sm-7">
                <input type="text" name="homeplace" value="${basicInfo.homeplace}" class="form-control">
              </div>
            </div>
          </div>
          <div class="col-lg-4">
            <div class="form-group">
              <label class="col-sm-5 control-label">性别：</label>
              <div class="col-sm-7">
                  <sys:select checkValue="${basicInfo.sex}" lists="${fns:getDictList('SEX_DICT')}" className="form-control" name="sex"></sys:select>              </div>
            </div>
            <div class="form-group">
              <label class="col-sm-5 control-label">出生日期：</label>
              <div class="col-sm-7">
                <input type="text" name="birthdayDate"  id="birthdayDate"
                       value="<fmt:formatDate value="${basicInfo.birthdayDate}" pattern="yyyy-MM-dd" type="date" dateStyle="long" />" onclick="WdatePicker({dateFmt:'yyyy-MM-dd',isShowClear:false});" class="form-control Wdate">
              </div>
            </div>
            <div class="form-group">
              <label class="col-sm-5 control-label">工作单位：</label>
              <div class="col-sm-7">
                <input type="text" name="unitInContract" value="${basicInfo.unitInContract}" class="form-control">
              </div>
            </div>
            <div class="form-group">
              <label class="col-sm-5 control-label">婚姻：</label>
              <div class="col-sm-7">
                <sys:select checkValue="${basicInfo.marriage}" lists="${fns:getDictList('MARRIAGE_DICT')}" className="form-control" name="marriage"></sys:select>
              </div>
            </div>
            <div class="form-group">
              <label class="col-sm-5 control-label">现住址：</label>
              <div class="col-sm-7">
                <input type="text" name="address" value="${basicInfo.address}" class="form-control">
              </div>
            </div>
          </div>
          <div class="col-lg-4">
            <div class="form-group" >
              <label class="col-sm-5 control-label">头像：</label>
              <div class="col-sm-7" >
                <input type="hidden" id="headPortrait" name="headPortrait" value="${basicInfo.headPortrait}"/>
                <img id="headImage" src="${basicInfo.headPortrait}" style="background:#B3B3B3;height:107px;width: 100%; "/>
                &nbsp;&nbsp;&nbsp;&nbsp;<label><a onclick="upLoadHeadPortrait()">（点击修改头像）</a></label>
              </div>
            </div>
            <div class="form-group">
              <label class="col-sm-5 control-label">职业：</label>
              <div class="col-sm-7">
                <sys:select checkValue="${basicInfo.identity}" lists="${fns:getDictList('PROFESSION_DICT')}" className="form-control" name="identity"></sys:select>
              </div>
            </div>
            <div class="form-group">
              <label class="col-sm-5 control-label">电话：</label>
              <div class="col-sm-7">
                <input type="text" name="phone"  data-parsley-mobilephone="ture"  data-parsley-validate="true" value="${basicInfo.phone}" class="form-control">
              </div>
            </div>
          </div>
        </fieldset>
        <div class="opertion_items">
          <div>体检信息</div>
        </div>
        <fieldset>
          <div class="col-lg-4">
            <div class="form-group">
              <label class="col-sm-5 control-label">体检日期：</label>
              <div class="col-sm-7">
                <input type="text" id="healthexamDate" name="tInformation.healthexamDate" value="<fmt:formatDate value="${tInformation.healthexamDate}" pattern="yyyy-MM-dd" type="date" dateStyle="long" />" onclick="WdatePicker({dateFmt:'yyyy-MM-dd',isShowClear:false});" class="form-control Wdate">
              </div>
            </div>
          </div>
          <div class="col-lg-4">
            <div class="form-group">
              <label class="col-sm-5 control-label">体检类型：</label>
              <div class="col-sm-7">
                <input type="hidden" id="type" value="${tInformation.type}"/>
                <select name="tInformation.type" class="form-control" id="tjType" onchange="tuanJian()" >
                  <c:forEach varStatus="type" begin="0" end="1">
                        <option value="${type.index}" ${type.index eq tInformation.type ? 'selected=\"selected\"' : ''}>
                          <c:if test="${type.index=='0'}">个检</c:if>
                          <c:if test="${type.index=='1'}">团检</c:if>
                        </option>
                  </c:forEach>
                </select>
              </div>
            </div>
          </div>
        </fieldset>
        <div id="tuanJian" >
        <div class="opertion_items">
          <div>团检信息</div>
        </div>
        <fieldset>
          <div class="col-lg-8">
            <div class="form-group">
              <label class="col-sm-2 control-label">单位：</label>
              <div class="col-sm-7">
                <input type="hidden" id="team" value="${tInformation.team}"/>
                <select name="tInformation.team" class="form-control" id="teamSelect" onchange="clickIn()" >
                  <c:forEach items="${baseUnit}" var="baseUnit">
                    <c:choose>
                      <c:when test="${baseUnit.id eq tInformation.team}">
                        <option value="${baseUnit.id}" selected="selected">${baseUnit.name}</option>
                      </c:when>
                      <c:otherwise>
                        <option value="${baseUnit.id}">${baseUnit.name}</option>
                      </c:otherwise>
                    </c:choose>
                  </c:forEach>
                </select>
              </div>
            </div>
            <div class="form-group">
              <label class="col-sm-2 control-label">分组：</label>
              <div class="col-sm-7" id="tUnitFzDiv">
                <select name="tInformation.teamGroup" class="form-control" id="teamGroup">
                  <c:forEach items="${tUnitFz}" var="tUnitFz">
                    <option value="${tUnitFz.id}" ${tUnitFz.id eq tInformation.teamGroup ? 'selected=\"selected\"' : ''}>${tUnitFz.name}</option>
                  </c:forEach>
                </select>
              </div>
            </div>
          </div>
          <div class="col-lg-4">
            <div class="form-group">
              <label class="col-sm-5 control-label">收费方式：</label>
              <div class="col-sm-7" id="payType" >
                <sys:select  checkValue="${tInformation.payType}" lists="${fns:getDictList('PAY_WAY_DICT')}" className="form-control" name="tInformation.payType" ></sys:select>
              </div>
            </div>
            <div class="form-group">
              <label class="col-sm-5 control-label">统收金额：</label>
              <div class="col-sm-7">
                <input type="text" id="unifiedPrice" name="tInformation.unifiedPrice" value="${tInformation.unifiedPrice}" class="form-control">
              </div>
            </div>
          </div>
        </fieldset>
        </div>
      </div>

      <div class="col-lg-1">
        <button type="submit"  class="btn btn-primary mb5">保存</button>
        <button type="button" class="btn btn-primary" onclick="print('${patientId}','${clinicId}')">打印</button>
      </div>

    </form>
  </div>
</div>